﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
                    xmlns:as="clr-namespace:Xtreem.GoogleSearch.AutoSuggest">
    <LinearGradientBrush x:Key="TextBoxBorder" EndPoint="0,20" StartPoint="0,0" MappingMode="Absolute">
        <GradientStop Color="#ABADB3" Offset="0.05"/>
        <GradientStop Color="#E2E3EA" Offset="0.07"/>
        <GradientStop Color="#E3E9EF" Offset="1"/>
    </LinearGradientBrush>

    <Style x:Key="AutoSuggestTextBoxStyle" TargetType="{x:Type as:AutoSuggestTextBox}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type as:AutoSuggestTextBox}">
                    <themes:ListBoxChrome x:Name="Bd"
                                          SnapsToDevicePixels="True"
                                          Background="{TemplateBinding Background}"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          BorderThickness="{TemplateBinding BorderThickness}"
                                          RenderFocused="{TemplateBinding IsKeyboardFocusWithin}"
                                          RenderMouseOver="{TemplateBinding IsMouseOver}">
                        <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,0,20,0"/>
                    </themes:ListBoxChrome>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="ListItemBackground" Color="#F1F1F1" />

    <Style x:Key="AutoSuggestListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="Border"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="True">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Margin="0 1 0 2" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" TargetName="Border"
                                    Value="{StaticResource ListItemBackground}" />
                            <Setter Property="Foreground" 
                                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="ListBorder" Color="#828790" />
    
    <Style x:Key="AutoSuggestListBoxStyle" TargetType="{x:Type ListBox}">
        <Setter Property="ItemContainerStyle" Value="{DynamicResource AutoSuggestListBoxItemStyle}" />
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FontSize" Value="18" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="Border"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="0"
                            SnapsToDevicePixels="True">
                        <ScrollViewer Focusable="False"
                                      Padding="{TemplateBinding Padding}"
                                      Template="{DynamicResource AutoSuggestScrollViewerControlTemplate}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" 
                                    TargetName="Border"
                                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <LinearGradientBrush x:Key="ResizeGripperForeground" EndPoint="1,0.75" StartPoint="0,0.25">
        <GradientStop Color="#FFFFFF" Offset="0.3" />
        <GradientStop Color="#BBC5D7" Offset="0.75" />
        <GradientStop Color="#6D83A9" Offset="1" />
    </LinearGradientBrush>

    <Style x:Key="AutoSuggestResizeGripStyle" TargetType="{x:Type ResizeGrip}">
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
        <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ResizeGrip}">
                    <Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                        <Path Name="RG_TRIANGLE" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                            <Path.Data>
                                <PathGeometry Figures="M17,-1 L -1,17 17,17" />
                            </Path.Data>
                        </Path>
                        <Path HorizontalAlignment="Right"
                              Margin="0,0,2,2"
                              VerticalAlignment="Bottom"
                              Data="M 9,0 L 11,0 L 11,11 L 0,11 L 0,9 L 3,9 L 3,6 L 6,6 L 6,3 L 9,3 z">
                            <Path.Fill>
                                <DrawingBrush TileMode="Tile"
                                              Viewbox="0,0,3,3"
                                              ViewboxUnits="Absolute"
                                              Viewport="0,0,3,3"
                                              ViewportUnits="Absolute">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="{StaticResource ResizeGripperForeground}"
                                                             Geometry="M 0,0 L 2,0 L 2,2 L 0,2 z " />
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Path.Fill>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <ControlTemplate x:Key="AutoSuggestScrollViewerControlTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid>
            <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Rectangle x:Name="Corner"
                           Grid.Column="1"
                           Grid.Row="1"
                           Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                CanContentScroll="{TemplateBinding CanContentScroll}"
                                CanHorizontallyScroll="False"
                                CanVerticallyScroll="False"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                Content="{TemplateBinding Content}"
                                Margin="{TemplateBinding Padding}" />
                <ScrollBar x:Name="PART_VerticalScrollBar"
                           AutomationProperties.AutomationId="VerticalScrollBar"
                           Cursor="Arrow"
                           Grid.Column="1"
                           Maximum="{TemplateBinding ScrollableHeight}"
                           Minimum="0"
                           Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                           Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                           ViewportSize="{TemplateBinding ViewportHeight}"
                           Margin="0 17 0 0" />
                <ScrollBar x:Name="PART_HorizontalScrollBar"
                           AutomationProperties.AutomationId="HorizontalScrollBar"
                           Cursor="Arrow"
                           Maximum="{TemplateBinding ScrollableWidth}"
                           Minimum="0"
                           Orientation="Horizontal"
                           Grid.Row="1"
                           Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                           Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                           ViewportSize="{TemplateBinding ViewportWidth}" />
            </Grid>

            <ResizeGrip Name="ResizeGrip"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Style="{DynamicResource AutoSuggestResizeGripStyle}"
                        Cursor="SizeNESW">
                <ResizeGrip.LayoutTransform>
                    <ScaleTransform ScaleX="1" ScaleY="-1" />
                </ResizeGrip.LayoutTransform>
            </ResizeGrip>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="ComputedVerticalScrollBarVisibility" Value="Visible">
                <Setter TargetName="ResizeGrip"
                Property="Background"
                Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="SearchButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="FontSize" Value="42" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="ButtonBorder" 
                            CornerRadius="3" 
                            BorderThickness="2" 
                            Background="#FF4A8BF4"
                            BorderBrush="#FF4A8BF4"
                            RenderTransformOrigin="0.5,0.5">
                        <ContentPresenter x:Name="ButtonContentPresenter"
                                          VerticalAlignment="Center"  
                                          Grid.RowSpan="2" 
                                          HorizontalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="RenderTransform" TargetName="ButtonBorder">
                                <Setter.Value>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="0.95" ScaleY="0.95"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" TargetName="ButtonBorder" Value="#FF0A55D3"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>